package org.ky.service.impl;

import org.ky.dao.SmbmsUserDao;
import org.ky.entity.SmbmsUser;
import org.ky.service.SmbmsUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service  //代表是业务层实现
public class SmbmsUserServiceImpl implements SmbmsUserService {

    //将数据库注入进来
    @Autowired
    private SmbmsUserDao smbmsUserDao;

    //登录功能的实现
    @Override
    public boolean login(String name, String password) {
        SmbmsUser user = smbmsUserDao.getUserByName(name);
        if(user!= null){
            //代表用户名存在
            if(user.getUserPassword().equals(password)){
                //登录成功
                return true;
            }else{
                //密码错误
                return false;
            }
        }
        return false;
    }

    //查询
    @Override
    public List<SmbmsUser> showList() {
        List<SmbmsUser> list = smbmsUserDao.showUserList();
        if(list.size()>0){
            return list;
        }else{
            return null;
        }
    }
}